package com.sxx.beautifulcity.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.TextView;

import com.sxx.beautifulcity.R;
import com.sxx.beautifulcity.application.ProjectApplication;
import com.sxx.beautifulcity.popmenu.CommonPopMenu;

/**
 * Created by dllo on 15/10/28.
 * 农家乐详情
 */
public class AgritourismDetailActivity extends DialogBaseActivity implements View.OnClickListener {
    //定义一个WebView
    private WebView agritourismWb;
    //定义一个接收从农家乐主界面传过来的id
    private String id;
    private TextView title , moreTv;
    private ImageView backIv;
    //定义一个图片加载缓存的url
    private String url;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview_agritourism_detail);
        init();
    }

    /**
     * 初始化控件
     */
    private void init() {
        title = (TextView) findViewById(R.id.titleTv);
        title.setText("农家院");
        moreTv = (TextView) findViewById(R.id.moreTv);
        moreTv.setOnClickListener(this);

        backIv = (ImageView) findViewById(R.id.backIV);
        backIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ProjectApplication.getContext(), AgritourismActivity.class);
                startActivity(intent);
                finish();
                overridePendingTransition(R.anim.left_out, R.anim.right_into);
            }
        });

        agritourismWb = (WebView) findViewById(R.id.agritourismWb);
        showDialog();
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        url = "http://www.365960.com/plus/api/article.php?sid=" + id;
        agritourismWb.loadUrl(url);
        dismissDialog();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.moreTv:
                //弹出一个PopMenu(因为每一个详情页面都需要弹出一样的PopMenu所以封装了一个PopMenu)
                PopupMenu menu = CommonPopMenu.setHelpShopPopMenu(v , url);
                break;
        }
    }
}
